package feature;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ken
 * Date: 2023-11-26
 * Time: 19:18
 */
public class FindOperation implements IOPeration{
    @Override
    public void work(BookList bookList) {
        System.out.println("查找图书");
        System.out.println("请输入你要找的图书名字");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        int countsize = bookList.getUsedSize();
        for (int i = 0; i < countsize; i++) {
            Book book = bookList.getBooks(i);
            if(book.getName().equals(name)) {
                System.out.println("找到了");
                System.out.println(bookList.getBooks(i));
                return;
            }
        }
        System.out.println("没有找到你想找的书");
    }
}
